package com.hbnu.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtils {
    private static Configuration configuration;
    private static SessionFactory sessionFactory;
    static {
        configuration=new Configuration().configure();
        sessionFactory=configuration.buildSessionFactory();
    }
    //对外提 供
    public static SessionFactory getSessionFactory(){
        return  sessionFactory;
    }

    //    返回与本地线程绑定的session
    public static Session getSession(){
        return sessionFactory.getCurrentSession();  //获取本地对象
    }

    public static void main(String[] args){

    }
}
